<style>
    * {
      padding: 0px;
      margin: 0px;
    }
    html,
    body,
    #root {
      width: 100%;
      height: 100%;
      overflow: hidden;  
    }
    #root {
      display: flex;
    }
  
    .menu {
      width: 200px;
      height: 100%;
      background: #263445;
      transition: all 0.3s;
    }
    .menu li {
      width: 100%;
      height: 50px;
      line-height: 50px;
      text-align: center;
      color: #fff;
    }
    .menu li:hover {
      background: gray;
      color: #263445;
      cursor: pointer;
    }
  
    .main {
      flex: 1;
      background: #fff;
      height: 50px;
      box-shadow: 0 1px 4px rgb(0 21 41 / 8%);
    }
    .main .top {
      display: flex;
      padding: 0px 10px;
      height: 100%;
      align-items: center;
      justify-content: space-between;
    }
    .main .content {
      width: 90%;
      height: 80%;
      margin: auto;
      margin: 50px;
    }
    .jiejie{
        width: 100%;
        height: 500px;
        background: gray;
        box-shadow: 0 1px 4px rgb(0 21 41 / 8%);

    }
  </style>
 
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.5.1" />
  <link rel="stylesheet" href="//at.alicdn.com/t/font_3232506_s3upk5984lo.css">
  
  <div id="root">
    <div class="menu" v-bind:style="{width: menuWidth}">
      <ul>
        <li @click=" who='index' ">后台首页</li>
        <li @click=" who='goods' ">商品管理</li>
        <li @click=" who='orders' ">订单管理</li>
    
      </ul>
    </div>
    <div class="main">
      <div class="top">
        <div>
            <i class="iconfont icon-category" @click="changeMenuWidthFn"></i>
          
          <span>首页 &gt; </span>
          <!-- <span
            v-for='item in [
                {url:"index", title: "aa"},
                {url:"goods", title: "nn"},
              ]'
            style="display: inline-block"
            v-if="item.url == who"
            class="animated bounceInRight"
            >{{item.title}}</span
          > -->
  
          <transition appear enter-active-class="animated flipOutX">
            <span
              v-for='item in [
                {url:"index", title: "后台首页&gt; 欢迎页"},
                {url:"goods", title: "商品管理&gt; 商品页"},
                {url:"orders", title: "订单管理&gt;     订单页"},
              ]'
              style="display: inline-block"
              v-if="item.url == who"
              :key="item.url"
              class="animated flipOutX"
              >{{item.title}}</span
            >
          </transition>
        </div>
        <button>退出</button>
      </div>
      <div class="content">
        <transition appear enter-active-class="animated flipOutY">
          <component :is="who"></component>
        </transition>
      </div>
    </div>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    // <li>后台首页</li>
    // <li>商品管理</li>
    // <li>订单管理</li>
    // <li>用户管理</li>
    Vue.component("index", {
      template: `
      <div class="jiejie">
        <fieldset>
            <legend>后台首页</legend>
            后台首页
        </fieldset>
      </div>
    `,
    });
  
    Vue.component("goods", {
      template: `
      <div class="jiejie">
      <fieldset>
      <legend>商品管理</legend>
      商品管理
    </fieldset>
    </div>
    `,
    });
  
    Vue.component("orders", {
      template: `
      <div class="jiejie">
      <fieldset>
      <legend>订单管理</legend>
      订单管理
    </fieldset>
    </div>
    `,
    });
  
    Vue.component("users", {
      template: `<fieldset>
      <legend>用户管理</legend>
      用户管理
    </fieldset>`,
    });
  
    const vm = new Vue({
      el: "#root",
      data: {
        who: "index",
        menuWidth: "200px",
      },
      methods: {
        changeMenuWidthFn() {
          console.log(this.menuWidth == "200px");
          this.menuWidth = this.menuWidth == "200px" ? "64px" : "200px";
        },
      },
    });
  </script>
  